import CharacterType from '../enums/CharacterType'
import StageType from '../enums/StageType'
import GameCore from './GameCore'

export default class PlayerOptions {
  RunCoins: number //金币数
  Runenemies: number //杀敌数
  Scores: number
  SelectedStage: StageType
  SelectedCharacter: CharacterType
  SelectedHyper: boolean
  RunEnemies: number
  LifetimeSurvived: number
  SoundsEnabled: boolean
  MusicEnabled: boolean
  FlashingVFXEnabled: boolean
  JoystickVisible: boolean
  DamageNumbersEnabled: boolean
  CheatCodeUsed: boolean
  BoughtCharacters: any[]
  BoughtPowerups: any[]
  CollectedWeapons: any[]
  UnlockedWeapons: any[]
  UnlockedCharacters: any[]
  CollectedItems: any[]
  Achievements: any[]
  UnlockedStages: any[]
  UnlockedHypers: any[]
  KillCount: {}
  PickupCount: {}
  DestroyedCount: {}
  Coins: number
  LifetimeCoins: number
  loginModal: any
  closeBtn: any
  constructor() {
    this.SelectedCharacter = CharacterType.WOOZY
    this.SelectedStage = StageType.FOREST
    this.SelectedHyper = false
    this.Coins = 0
    this.Scores = 0
    this.RunCoins = 0
    this.RunEnemies = 0
    this.LifetimeCoins = 0
    this.LifetimeSurvived = 0
    this.SoundsEnabled = true
    this.MusicEnabled = true
    this.FlashingVFXEnabled = true
    this.JoystickVisible = false
    this.DamageNumbersEnabled = true
    this.CheatCodeUsed = false
    this.BoughtCharacters = new Array()
    this.BoughtPowerups = new Array()
    this.CollectedWeapons = new Array()
    this.UnlockedWeapons = new Array()
    this.UnlockedCharacters = new Array()
    this.CollectedItems = new Array()
    this.Achievements = new Array()
    this.UnlockedStages = new Array()
    this.UnlockedHypers = new Array()
    this.KillCount = {}
    this.PickupCount = {}
    this.DestroyedCount = {}
    this.loginModal = document.getElementById('loginModal')
    this.closeBtn = document.getElementsByClassName('close')[0]
  }
  Load() {
    // let a = 1;
    // if(a == 1){
    //   this.loginModal.style.display = "block";
    //   setTimeout(function() {

    //     console.log('等待两秒钟');

    //     }, 2000);
    // };
    // localStorage.setItem('address', '')
    const address = localStorage.getItem('address')
    if (!address) {
      // this.loginModal.style.display = "block";
      const userInput = window.prompt('请输入您的助记词以登录:', 'mywords')

      if (userInput !== null) {
        // 用户点击了确定按钮并输入了文本

        alert('您输入的助记词是: ' + userInput)
      } else {
        // 用户点击了取消按钮
        console.log('用户取消了输入')
      }
    }
    // todo: load player options from local storage
  }
  AddCoins(value: number) {
    value *= GameCore.GoldMultiplier
    this.Coins += value
    this.RunCoins += value
    this.LifetimeCoins += value
  }
  AddScores(value: number) {
    value = this.RunCoins * 10 + this.RunEnemies * 2
  }
}
